#include "mysql.h"




int get_file_hash_from_db1(int *now_addr,MYSQL*mysql,char*md5) {
    char query[256];
    snprintf(query, sizeof(query),
             "SELECT id FROM vft WHERE md5='%s'",md5);

   mysql_query(mysql, query);
   MYSQL_RES *rows=mysql_store_result(mysql);
   if(mysql_num_rows(rows)==0){                                        
       return 0;
   }
    MYSQL_ROW row=mysql_fetch_row(rows);
    md5=row[0];
    return 1;
}


int get_file_hash_from_db(char * now_addr,MYSQL*mysql,char*md5) {
    char query[256];
    snprintf(query, sizeof(query), 
             "SELECT md5 FROM vft WHERE path='%s'",now_addr);

   mysql_query(mysql, query);
   MYSQL_RES *rows=mysql_store_result(mysql);
   if(mysql_num_rows(rows)==0){
       return 0;   
   }
    MYSQL_ROW row=mysql_fetch_row(rows);
    md5=row[0];

   // MYSQL_RES *result = mysql_store_result(db_conn);
   // if (!result) {
   //   fprintf(stderr, "Store result error: %s\n", mysql_error(db_conn));
   // return -1;
   // }

    //MYSQL_ROW row = mysql_fetch_row(result);
    //if (!row) {
    //   fprintf(stderr, "File not found: %s\n", filename);
    //    mysql_free_result(result);
    //    return -1;
    //}

    // 复制哈希值到输出参数

    //mysql_free_result(result);
    return 1;
}

